//package com.zmn.plat.dubbo.impl.channel;
//
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.date.DateUtil;
//import com.zmn.mcc.cas.model.LoginStaff;
//import com.zmn.plat.business.interfaces.channel.ChannelBService;
//import com.zmn.plat.common.dto.channel.ChannelBrandSiteAddDIO;
//import com.zmn.plat.common.dto.channel.ChannelDRO;
//import com.zmn.plat.dubbo.dto.channel.ChannelAddDIO;
//import com.zmn.plat.dubbo.dto.channel.ChannelCommissionDIO;
//import com.zmn.plat.dubbo.interfaces.channel.ChannelModifyRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.channel.Channel;
//import com.zmn.plat.model.entity.channel.ChannelAddVO;
//import com.zmn.plat.model.entity.channel.ChannelCommission;
//import com.zmn.plat.services.interfaces.channel.ChannelService;
//import lombok.extern.log4j.Log4j2;
//import org.apache.dubbo.config.annotation.Service;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cglib.beans.BeanCopier;
//
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * The type Channel modify remote service.
// *
// * @author xiangjunming
// * @since 2019/12/24 16:41:18
// */
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//@Log4j2
//public class ChannelModifyRemoteServiceImpl implements ChannelModifyRemoteService {
//
//    @Autowired
//    private ChannelBService channelBService;
//
//    @Autowired
//    private ChannelService channelService;
//
//    @Override
//    public ResponseDTO<ChannelDRO> addChannel(ChannelAddDIO channelAddDIO) {
//        log.info("ChannelModifyRemoteServiceImpl.addChannel参数channelAddDIO：{}", channelAddDIO);
//        ChannelAddVO newChannel = new ChannelAddVO();
//        BeanCopier copier = BeanCopier.create(ChannelAddDIO.class, ChannelAddVO.class, false);
//        copier.copy(channelAddDIO, newChannel, null);
//        LoginStaff loginStaff = new LoginStaff();
//        loginStaff.setType(GlobalConsts.OPERATE_USER_TYPE_STAFF);
//        loginStaff.setStaffId(GlobalConsts.NO);
//        loginStaff.setStaffName("SYSTEM");
//        channelBService.addChannel(newChannel, loginStaff);
//        Channel createChannel = channelService.findByKey(newChannel.getChannelId());
//        copier = BeanCopier.create(Channel.class, ChannelDRO.class, false);
//        ChannelDRO dro = new ChannelDRO();
//        copier.copy(createChannel, dro, null);
//        return ResponseDTO.success(dro);
//    }
//
//    @Override
//    public ResponseDTO<ChannelDRO> addChannelForBrandSite(ChannelBrandSiteAddDIO channel) {
//        log.info("ChannelModifyRemoteServiceImpl.addChannelForBrandSite参数channel：{}", channel);
//        Channel result = channelBService.addBrandSiteChannel(channel);
//        Channel createChannel = channelService.findByKey(result.getChannelId());
//        BeanCopier copier = BeanCopier.create(Channel.class, ChannelDRO.class, false);
//        ChannelDRO dro = new ChannelDRO();
//        copier.copy(createChannel, dro, null);
//        return ResponseDTO.success(dro);
//    }
//
//    @Override
//    public ResponseDTO<ChannelDRO> modifyChannel(ChannelAddDIO channelAddDIO) {
//        log.info("ChannelModifyRemoteServiceImpl.modifyChannel参数channelAddDIO：{}", channelAddDIO);
//        Channel newChannel = new Channel();
//        BeanCopier copier = BeanCopier.create(ChannelAddDIO.class, Channel.class, false);
//        copier.copy(channelAddDIO, newChannel, null);
//        channelBService.updateByKeySelective(newChannel);
//        newChannel = channelService.findByKey(newChannel.getChannelId());
//        copier = BeanCopier.create(Channel.class, ChannelDRO.class, false);
//        ChannelDRO dro = new ChannelDRO();
//        copier.copy(newChannel, dro, null);
//        return ResponseDTO.success(dro);
//    }
//
//    @Override
//    public ResponseDTO<Void> modifyCommissions(List<ChannelCommissionDIO> commissions, String operator) {
//        log.info("ChannelModifyRemoteServiceImpl.modifyCommissions参数commissions：{}，operator：{}", commissions, operator);
//        List<ChannelCommission> list = commissions.stream().map(item -> new ChannelCommission() {
//            {
//                setChannelId(item.getChannelId());
//                setServCategId(item.getServCategId());
//                setCommissionTypeNew(item.getCommissionType());
//                setCommissionNew(item.getCommission().floatValue());
//                setEffectiveTime(DateUtil.getNow());
//            }
//        }).collect(Collectors.toList());
//        channelBService.modifyCommissions(list, operator);
//        return ResponseDTO.success();
//    }
//}
